<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        class Stu {
            printName(name) {
                console.log(this);
                this.print(name) 
            }
            print(val) {
                console.log(`I am ${val}`);
            }
        }

        let stu1 = new Stu();
        console.log(stu1);
        // let {print:print, printName: printName} = stu1; // 完整写法
        let {print, printName} = stu1; // 缩写,对象中的key和value相同时，只保留一个即可
        // stu1.printName('马某某')
        printName('马什么梅') 
        // 报错的原因是this是undefined，所以不能读取print。在严格模式下，这种函数中的this等于undefined
    </script>
</body>
</html>